
// 解决H5跨域问题， 临时修改，APP需要改回来
// let api = '/api'
let api="https://weixin.sleephouse.cn/core/api"
let codeerr = false;
let http = function(obj){
	let headers =  {
      'content-type': 'application/json'
    };
	
	if(uni.getStorageSync('user')){
		headers =  {
		  'content-type': 'application/json', // 默认值
		  'Cookie': 'JSESSIONID=' + uni.getStorageSync('user').sessionId
		};
	}
	return new Promise(function(resolve, reject){
		uni.request({
			url: api + obj.url,
			data: obj.data,
			header:headers,
			method:"POST",
			success: (res)=>{
				resolve(res.data)
			},
			fail: (err)=>{
				reject(err.response)
			}
		})
	})
}




export{
    http,
	api
};
 